package com.hand.wfive.entity

import android.os.Build
import android.os.Parcel
import android.os.Parcelable
import androidx.annotation.RequiresApi

class PickerFileModel {
    var type = Params.pickerImage
    var name = ""
    var time = ""
    var size = ""
    var path = ""
    var select=false
}

class FileListModel {
    var code = 0
    var msg = ""
    var data = FileDataModel()
    override fun toString(): String {
        return "FileListModel(code=$code, msg='$msg', data=$data)"
    }

}
class OrderStatusModel {
    var code = 0
    var msg = ""
    var data = 0 // 支付状态 0-未支付 1-支付中 2-支付成功 3-支付失败 4-已取消
}
class FileWord2ImagesModel {
    var code = 0
    var msg = ""
    var data = ""
}

class BaseModel {
    var code = 0
    var msg = ""
}

data class WordFileCountModel(
    val code: Int,
       val msg: String,
       val `object`: Int
)


class FileDataModel {
    var size = 0
    var pages = 0
    var current = 0
    var records = ArrayList<FileModel>()
    override fun toString(): String {
        return "FileDataModel(size=$size, pages=$pages, current=$current, records=$records)"
    }

}

class FileModel() : Parcelable {
    var id = 0L
    var wordToImageId = 0L
    var size = 0L
    var type = ""
    var status = ""
    var fileId = ""
    var fileName = ""
    var updateTime = ""
    var coverFileId = ""

    var filePath = ""
    var coverPath = ""
    var select=false //为序列化

    @RequiresApi(Build.VERSION_CODES.Q)
    constructor(parcel: Parcel) : this() {
        id = parcel.readLong()
        wordToImageId = parcel.readLong()
        size = parcel.readLong()
        type = parcel.readString() ?: ""
        status = parcel.readString() ?: ""
        fileId = parcel.readString() ?: ""
        fileName = parcel.readString() ?: ""
        updateTime = parcel.readString() ?: ""
        coverFileId = parcel.readString() ?: ""

        filePath = parcel.readString() ?: ""
        coverPath = parcel.readString() ?: ""

    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other !is FileModel) return false
        if (fileId != other.fileId) return false
        return true
    }

    override fun hashCode(): Int {
        return fileId.hashCode()
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeLong(id)
        parcel.writeLong(wordToImageId)
        parcel.writeLong(size)
        parcel.writeString(type)
        parcel.writeString(status)
        parcel.writeString(fileId)
        parcel.writeString(fileName)
        parcel.writeString(updateTime)
        parcel.writeString(coverFileId)

        parcel.writeString(filePath)
        parcel.writeString(coverPath)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<FileModel> {
        override fun createFromParcel(parcel: Parcel): FileModel {
            return FileModel(parcel)
        }

        override fun newArray(size: Int): Array<FileModel?> {
            return arrayOfNulls(size)
        }
    }

    fun copy(): FileModel {
        val fileModel = FileModel()
        fileModel.id = id
        fileModel.wordToImageId = wordToImageId
        fileModel.size = size
        fileModel.type = type
        fileModel.status = status
        fileModel.fileId = fileId
        fileModel.fileName = fileName
        fileModel.updateTime = updateTime
        fileModel.coverFileId = coverFileId

        fileModel.filePath = filePath
        fileModel.coverPath = coverPath
        return fileModel
    }

    override fun toString(): String {
        return "FileModel(id=$id,wordToImageId=$wordToImageId, size=$size, type='$type', status='$status', fileId='$fileId', fileName='$fileName', updateTime='$updateTime', coverFileId='$coverFileId', filePath='$filePath', coverPath='$coverPath')"
    }
}